class Banner{
		//判断一个类是否需要参数
		//从HTML是否需要获取元素
		constructor(newImg) {
		    this.index = 0;
			this.oImg = newImg;
			this.oImg.style.backgroundImage = "url(img/index/"+this.index+".jpg)";
		}
		
		//设置背景
		setBgcImage(){
			this.oImg.style.backgroundImage = "url(img/index/"+this.index+".jpg)";
		}
		
		next(){
			this.index++;
			
			if(this.index == 3){
				this.index = 0;
			}
			
			this.setBgcImage();
		}
		
		prev(){
			this.index--;
			
			if(this.index == -1){
				this.index = 3 - 1;
			}
			
			this.setBgcImage();
		}
		
		startMove(){
			let that = this;
			 let time = null;
			time = setInterval(function(){
				that.next();
					
			},2000);
			this.oImg.onmouseover=function(){
				clearInterval(time);
			}
			this.oImg.onmouseout=function(){
				that.startMove();
			}
			
		}
		
		getEvent(){
			let oBtnNext = document.getElementById("btn-next");
			let oBtnPrev = document.getElementById("btn-previous");
			
			let that = this;
			
			that.startMove();
			oBtnNext.onclick = function(){
				that.next();
			}
			
			oBtnPrev.onclick = function(){
				that.prev();
			}
		
		}
	}
	
	